var strStr = function (haystack, needle){
    const Hlen = haystack.length
    const Nlen = needle.length
    if(Hlen < Nlen){
        return -1;
    }

    else if(Hlen == Nlen){
        if(haystack == needle){
            return 0
        }else{
            return -1
        }
    }

    else{
        for(var i = 0;i < Hlen - Nlen;i++){
            if(haystack[i] != needle[0]){
                continue;
            }

            if(haystack.substring(i,i+Nlen) == needle){
                return i;
            }
        }
    }

    return -1;
}

var a = strStr( 'hello world','ll')
console.log(a);


